*final update 2025.02.03



********************************************************************************
//STEP 01: CREATE LOCALS
********************************************************************************
//Declare dataset a panel
tsset 	id_city id_time

*Directory to the Alpha_Do_File .do file's location
local 	home_folder "/Users/demattee/Desktop/JLC_Replication"

local MA		"5"					// What is MA's id_city? UNSURE: tab id_city if hearing_base_city=="BOS", nolab
local units		"24"				// How many jurisdictions are there?

//IDENTIFY THE STATING DATES
local begin		"1"					// The first id_time in the analysis
local MSPEstart "1"					// Period in which MSPE minimization begins 														
		
//IDENTIFY THE TREATMENT DATES
local pretreat	"38"				// What id_time corresponds with the Brito vs. Barr decision date
local decision	"39"				// Brito vs. Barr opinion published (Wednesday, Nov 27, 2019).
										// id_time	time	date_day
										// 32		201948	2019.11.27
									// court orders that immigration courts shall follow the requirements, effective Friday, December 13, 2019.
										// id_time	time	date_day
										// 34		201950	2019.12.13
local posttreat "40"				// What is the first id_time after the decision date? UNSURE: decision +1

//IDENTIFY THE ENDING DATES
local endtime	"52"				// id_time 53==2020 week 12 (Friday, March 20th) as the last id_time in the analysis?
local covid		"52"				// POTUS Declares COVID-19 a National Emergency (Friday, March 13).
										
//Set locals to ensure that all analyses run the same model
local outcome 	"granted_bond"													 
local pretime 	"granted_bond(13) granted_bond(17) granted_bond(20) granted_bond(38)"
local court		"trump_ij obama_ij ij_experience"								
local case		"crime_charge_yes meeting_number"								
local econ		"log_state_gdp"													
local society	"log_state_pop state_govt_employees_capita"	


********************************************************************************
// STEP 02: USE LOOPS TO CALCULATE TWO RMSPES FOR EACH UNIT (ONE PRE AND ONE POST)
********************************************************************************

*Tell Stata where to save these .dta files it generates
cd "`home_folder'/Data/Placebo Results Granted Bond/Weekly"		

	tempname ratios
	foreach i of numlist 1/`units' {	
		synth 	`outcome' 														///
				`pretime' `court' `case' `politics' `econ' `society'			///
				, trunit(`i') trperiod(`decision') 								///
				mspeperiod(`MSPEstart'(1)`pretreat')							/// 
				nested /// allopt		  										/// no figure
				keep(RMSPE_`i') replace
		matrix `ratios' = nullmat(`ratios') \ e(RMSPE)
		local names `names' RMSPE_`i'
        }
		
		mat list `ratios'

	 			mat colnames `ratios' = "RMSPE"
				mat rownames `ratios' = `names'
				matlist `ratios' , row("Treated Unit")



********************************************************************************
// STEP 03: Return to JLC_01a_Synth_Granted_Bond_Weekly.do
********************************************************************************
